<?php
/**
* @package YARBB
* @copyright Авторские права (C) 2009 www.yar-it.com. Все права защищены.
* @license Лицензия http://www.gnu.org/licenses/gpl-2.0.htm GNU/GPL, или help/license.php
* YARBB! - свободное программное обеспечение распространяемое по условиям лицензии GNU/GPL
* Для получения информации о используемых расширениях и замечаний об авторском праве, смотрите файл copyright.php.
*/
	defined( '_JEXEC' ) or die( 'Restricted Access' );
	require_once ('components/com_yarbb/assets/ybbeditor/ybbeditor.php');
	$dispclr = $this->theme;
	global $ybbConfig;
	$bbcode = new ybbEditor();
	$userArray = array();
?>

<form action="<?php echo $this->action; ?>" method="post" name="FrmPostlist" id="FrmPostlist">
  <div class="ybbmaindiv">
    <table class="ybbnormaltable" cellpadding="0" cellspacing="0">
      <tr>
        <td class="ybbtopleft"></td>
        <td class="ybbtopmiddle">&nbsp;<?php echo $ybbConfig->boardname;?> </td>
        <td class="ybbtopright"></td>
      </tr>
      <tr>
        <td class="ybbleftbody"></td>
        <td class="ybbheaderrow"><table class="ybbnormaltable" cellpadding="5" cellspacing="5">
            <tr>
               <td><div id="yarbb_menu">
                <ul id="ybbmenu">
                  <?php echo $this->userprofile['home']; ?>
                  <li class="node"><a>Инструменты</a>
                    <ul>
                      <?php echo $this->userprofile['latest']; ?> 
					  <?php echo $this->userprofile['link']; ?> 
					  <?php echo $this->userprofile['mylist']; ?> 
					  <?php echo $this->userprofile['approval']; ?>
                    </ul>
                  </li>
                </ul>
              </div></td>
              <td class="ybbheaderusername"><?php echo JText::_('WELCOME') . ' ' . $this->userprofile['boardusername']; ?></td>
              <td class="ybbheaderavatar"><?php echo $this->userprofile['thumb']; ?></td>
            </tr>
          </table></td>
        <td class="ybbrightbody"></td>
      </tr>
      <?php foreach($this->sticky as $rec) { ?>
      <tr>
        <td class="ybbleftbody"></td>
        <td class="ybbheaderrow"><table class="ybbnormaltable" cellpadding="0" cellspacing="0">
            <tr>
              <td class="ybbtopicicon"><img src="<?php echo YARBB_ASSETS_URL_THEME.'/'.$dispclr; ?>/img/sticky<?php echo $rec->topic_type; ?>.gif" class="ybbiconimg" alt="sticky" /></td>
              <td class="ybblinetop"><a href="<?php echo JRoute::_('index.php?option=com_yarbb&view=postlist&forum=' . (int)$rec->forum_id . '&topic=' . (int)$rec->id.'&Itemid=' . $ybbConfig->itemid ); ?>"> <b><?php echo $this->escape($rec->post_subject); ?></b> </a>&nbsp; </td>
              <td class="ybbfrmlast" ><?php
                                if( $rec->post_time != 0 ) {
                                    if( $rec->post_user > 0 ) {
                                        if( isset( $userArray[$rec->post_user])) {
                                            $uname = $userArray[$rec->post_user];
                                        } else {
                                            $uname = yarbbHelperConfig::getUserName( $rec->post_user );
                                            $userArray[$rec->post_user] = $uname;
                                        }
                                        $uname = '<a href="'. JRoute::_('index.php?option=com_yarbb&view=myprofile&cid=' . $rec->post_user . '&Itemid=' . $ybbConfig->itemid ) . '">' . $uname . '</a>';
                                    } else {
                                        $uname = $rec->post_username;
                                    }
                                }
                                echo JText::_('POST_LIST_BY') . '&nbsp;<b>'. $uname . '</b>&nbsp;' . JText::_('POST_LIST_ON') . '&nbsp;' .
                                        JHTML::_('date', $rec->post_time + $ybbConfig->timeoffset, $ybbConfig->dateformat);
                            ?>
              </td>
            </tr>
          </table></td>
        <td class="ybbrightbody"></td>
      </tr>
      <?php }	?>
      <tr class="ybbtablefooter">
        <td class="ybbbotleft"></td>
        <td class="ybbbotmiddle"></td>
        <td class="ybbbotright"></td>
      </tr>
      <tr>
        <td colspan="3" class="ybbcolspacer"></td>
      </tr>
      <tr>
        <td colspan="3" class="ybbtpkpages"><?php if(count($this->items) > 0 ) echo $this->pagination->getPagesLinks(); ?>
        </td>
      </tr>
      <?php
       	$userArray = array();
		foreach ($this->items as $item) {
				if( isset( $userArray[$item->post_user])) {
					$postuser = $userArray[$item->post_user];
				} else {
					$postuser = yarbbHelperConfig::getUserProfile($item->post_user);
					$userArray[$item->post_user] = $postuser;
				}
		?>
      <tr>
        <td class="ybbtopleft"></td>
        <td class="ybbtopmiddle"><span class="ybbdvsubject">&nbsp;<?php echo $this->labels['subject'] . substr($this->escape($item->post_subject),0,70).'..'; ?></span> <span class="ybbdvpostime"><?php echo JHTML::_('date', $item->post_time + $ybbConfig->timeoffset, $ybbConfig->dateformat); ?>&nbsp;</span> </td>
        <td class="ybbtopright"></td>
      </tr>
      <tr>
        <td class="ybbleftbody"></td>
        <td><table class="ybbnormaltable" cellpadding="0" cellspacing="6">
            <tr>
              <td class="ybbuserinfo"><table class="ybbnormaltable" cellpadding="5" cellspacing="0">
                  <tr>
                    <td class="ybbpstusername"><b><?php echo $item->post_user > 0 ? $postuser['username'] : $item->post_username; ?></b></td>
                  </tr>
                  <tr>
                    <td class="ybbpostcenter"><a rel="nofollow" onFocus="blur();" href="<?php echo $postuser['profilelink']; ?>" > <?php echo $postuser['avatar']; ?> </a>
                      <?php if( $item->post_user < 1 ) { echo '<br/>'. JText::_('YBB_GUEST'); } ?>
                    </td>
                  </tr>
                  <?php if ($ybbConfig->showrank  > 0 && $item->post_user > 0) { ?>
                  <tr>
                    <td class="ybbpostcenter"><?php echo $postuser['rank_title']; ?></td>
                  </tr>
                  <tr>
                    <td class="ybbpostcenter"><img src="<?php echo YARBB_ASSETS_URL . '/ranks/' . $postuser['rank_image'] ; ?>" /></td>
                  </tr>
                  <?php } ?>
                  <?php if($item->post_user > 0 ) { ?>
                  <tr>
                    <td class="ybbpostuserdetails"><b><?php echo $this->labels['joined']; ?></b>:&nbsp;<?php echo JHTML::_('date', $postuser['registerdate'], $ybbConfig->dateformat); ?><br/>
                      <b><?php echo $this->labels['post']; ?></b>:&nbsp;<?php echo number_format($postuser['post_count']); ?><br/>
                      <b><?php echo $this->labels['location']; ?></b>:&nbsp;<?php echo $postuser['location']; ?> </td>
                  </tr>
                  <?php } ?>
                  <?php if ($ybbConfig->userprofile == 'yarbb' && $item->post_user > 0 ) { ?>
                  <tr>
                    <td class="ybbpostcenter"><span class="ybbposticons">
                      <?php
							                		// if((int)$postuser['showemail'] 	== 1) echo '<img src="' . 'components/com_yarbb/assets/icon_email.gif" height="20" width="20" 	title="' . $postuser['email'] . '"/>&nbsp;';
													if($postuser['www']		<> '') echo '<img src="' . 'components/com_yarbb/assets/icon_www.gif" height="20" width="20" title="' . $postuser['www'] . '" />&nbsp;';
													if($postuser['icq'] 	<> '') echo '<img src="' . 'components/com_yarbb/assets/icon_icq.gif" height="20" width="20" title="' . $postuser['icq'] . '" />&nbsp;';
													if($postuser['aol'] 	<> '') echo '<img src="' . 'components/com_yarbb/assets/icon_aol.gif" height="20" width="20" title="' . $postuser['aol'] . '" />&nbsp;';
													if($postuser['msn'] 	<> '') echo '<img src="' . 'components/com_yarbb/assets/icon_msn.gif" height="20" width="20" title="' . $postuser['msn'] . '" />&nbsp;';
													if($postuser['yahoo'] 	<> '') echo '<img src="' . 'components/com_yarbb/assets/icon_yahoo.gif" height="20" width="20" title="' . $postuser['yahoo'] . '" />&nbsp;';
													if($postuser['jabber'] 	<> '') echo '<img src="' . 'components/com_yarbb/assets/icon_jabber.gif" height="20" width="20" title="' . $postuser['jabber'] . '" />&nbsp;';
													if($postuser['skype'] 	<> '') echo '<img src="' . 'components/com_yarbb/assets/icon_skype.gif" height="20" width="20" title="' . $postuser['skype'] . '" />';
						                		?>
                      </span> </td>
                  </tr>
                  <?php } ?>
                </table></td>
              <td class="ybbpostarea"><table class="ybbposttable"  cellpadding="0" cellspacing="0">
                  <tr>
                    <td><div  class="ybbkarma">
                        <ul class="ybbkarmapanel">
                          <li class="ybbkarmapanelrpt"><a rel="nofollow" href="<?php echo JRoute::_($this->posturl . 'list&forum=' . $item->forum_id . '&topic=' . $item->topic_id . '&post=' . $item->id . '&postreport=1&Itemid=' . $ybbConfig->itemid); ?>" title="<?php echo JText::_('REPORT_ABUSE'); ?>" ><img src="images/blank.png" height="14" width="14" border="0" /></a></li>
                          <?php if( $ybbConfig->showkarma > 0  && $item->post_user > 0 ) { ?>
                          <li class="ybbkarmapaneltotal"><?php echo $postuser['karma']; ?></li>
                          <li class="ybbkarmapaneldown"><a rel="nofollow" href="<?php echo JRoute::_($this->posturl . 'list&task=karmaDown&forum=' . $item->forum_id . '&topic=' . $item->topic_id . '&post=' . $item->id . '&post_user=' . $item->post_user); ?>" title="<?php echo JText::_('VOTE_DOWN'); ?>"> <img src="images/blank.png" height="14" width="14" border="0" /> </a></li>
                          <li class="ybbkarmapanelup"><a rel="nofollow" href="<?php echo JRoute::_($this->posturl . 'list&task=karmaUp&forum=' . $item->forum_id . '&topic=' . $item->topic_id . '&post=' . $item->id . '&post_user=' . $item->post_user); ?>" title="<?php echo JText::_('VOTE_UP'); ?>"><img src="images/blank.png" height="14" width="14" border="0" /> </a></li>
                          <?php } ?>
                        </ul>
                      </div></td>
                  </tr>
                  <tr>
                    <td class="ybbposttextcol"><?php echo $this->labels['forum']; ?> <a href="<?php echo JRoute::_('index.php?option=com_yarbb&view=topiclist&forum='. $item->forum_id . '&Itemid='.$ybbConfig->itemid); ?>"> <u><b><i><?php echo $this->escape($item->forum_name); ?></i></b></u> </a><br/>
                      <?php echo $this->labels['topic']; ?> <a href="<?php echo JRoute::_('index.php?option=com_yarbb&view=postlist&forum='.$item->forum_id .'&topic='.$item->topic_id.'&Itemid='. $ybbConfig->itemid . $this->postlistmodel->getPageNumber($item->topic_id, $item->id) ); ?>"> <u><b><i><?php echo $this->escape($item->topic_subject); ?></i></b></u> </a><br/>
                      <br/>
                      <?php
										if( strlen($item->post_subject) > 70 ) {
											echo  '<u><b>'. $this->labels['subject'] . '<i>'. $this->escape($item->post_subject) . '</i></u></b><br/><br/>';
										}
										if( $ybbConfig->ybbeditor == 'yarbb' ) {
												echo $bbcode->parseContent($item->post_text);
											} else {
												echo $item->post_text;
											}
											$attachments = $this->postlistmodel->getAttachments( $item->id);
											if( count($attachments) > 0 ) {
												echo '<br/><div class="attachbox">';
												echo '<strong>' . JText::_('ATTACHMENTS') . '</strong>' ;
												foreach($attachments as $key => $value)
												{
													echo '<br/><img src="' . YARBB_ASSETS_URL_THEME .'/'.$dispclr. '/img/attach.png" />&nbsp;';
													echo '<a href="' . YARBB_ASSETS_URL . '/uploads/' . $value[0] . '">'. $value[1] . ' [' . (int) ($value[3]/1024) . ' KB]</a> :: '. $value[5];
												}
												echo '</div>';
											}
										?>
                    </td>
                  </tr>
                  <?php if( (isset($item->ip)?$item->ip:'') <> '' ){ ?>
                  <tr>
                    <td class="ybbpostlogip"><img src="<?php echo YARBB_ASSETS_URL_THEME.'/'.$dispclr; ?>/img/ip.gif" /> <small><?php echo $this->labels['logip']; ?></small> </td>
                  </tr>
                  <?php } ?>
                  <?php if( $ybbConfig->showeditmarkup > 0 && $item->modified_time > 0) { ?>
                  <tr>
                    <td class="ybbpostmod"><span class="ybbpostmodified">
                      <?php
											if( $item->modified_by > 0 ) {
												if( isset( $userArray[$item->modified_by])) {
													$modifyuser = $userArray[$item->modified_by];
												} else {
													$modifyuser  = yarbbHelperConfig::getUserProfile($item->modified_by);
													$userArray[$item->modified_by] = $modifyuser;
												}
											} else {
												$modifyuser = $item->post_username;
											}
											echo $this->labels['lastedit'] . ': ' .
												JHTML::_('date', $item->modified_time + $ybbConfig->timeoffset, $ybbConfig->dateformat) . ' ' .
												$this->labels['lasteditby'] . ' ' . $modifyuser['username'] . ' '.
												$this->labels['lasteditreason'] . ' ' . $item->modified_reason ;
										?>
                      </span> </td>
                  </tr>
                  <?php } ?>
                  <?php if( $postuser['signature'] <> '' ) { ?>
                  <tr>
                    <td class="ybbpostsignature"><?php echo $bbcode->parseContent($postuser['signature']);?> </td>
                  </tr>
                  <?php } ?>
                </table></td>
            </tr>
          </table></td>
        <td class="ybbrightbody"></td>
      </tr>
      <tr class="ybbtablefooter">
        <td class="ybbbotleft"></td>
        <td class="ybbbotmiddle"></td>
        <td class="ybbbotright"></td>
      </tr>
      <tr>
        <td colspan="3" class="ybbcolspacer"></td>
      </tr>
      <?php	}	?>
      <tr>
        <td colspan="3" class="ybbtpkmenu"><table class="ybbnormaltable" cellpadding="0" cellspacing="0">
            <tr>
              <td class="ybbfrmrowcol5"><?php if(count($this->items) > 0 ) { echo JText::_('PAGE') . ' #&nbsp;'; echo $this->pagination->getLimitBox(); } ?>
              </td>
              <td class="ybbtpkpages"><?php if(count($this->items) > 0 ) echo $this->pagination->getPagesLinks(); ?>
              </td>
            </tr>
          </table></td>
      </tr>
    </table>
  </div>
  <input type="hidden" name="option" value="com_yarbb" />
</form>
<br/>
<br/>
<?php echo YARBB_COPYRIGHT; ?> <br/>
<br/>
